package systemlog

import (
	"context"
	"go-caipu/pkg/services/dto"
)

type GetSysLoginLogPageCommand struct {
	BeginTime      string `form:"beginTime" search:"type:gte;column:login_time;table:sys_login_log" comment:"创建时间"`
	EndTime        string `form:"endTime" search:"type:lte;column:login_time;table:sys_login_log" comment:"创建时间"`
	Status         int    `form:"status"  search:"type:exact;column:status;table:sys_login_log" comment:""`
	dto.Pagination `search:"-"`
}

type SysLoginLog struct {
	Id            int64  `json:"id" gorm:"primaryKey;autoIncrement;comment:主键编码"`
	Username      string `json:"createUserString" gorm:"type:varchar(128);comment:用户名"`
	Status        int    `json:"status" gorm:"type:int;comment:状态"`
	Ipaddr        string `json:"ip" gorm:"type:varchar(32);comment:IP地址"`
	LoginLocation string `json:"address" gorm:"type:varchar(128);comment:归属地"`
	Browser       string `json:"browser" gorm:"type:varchar(255);comment:浏览器"`
	Os            string `json:"os" gorm:"type:varchar(255);comment:系统"`
	Platform      string `json:"platform" gorm:"type:varchar(255);comment:固件"`
	LoginTime     string `json:"createTime" gorm:"type:varchar(50);comment:登录时间"`
	Remark        string `json:"remark" gorm:"type:varchar(255);comment:备注"`
	Msg           string `json:"description" gorm:"type:varchar(255);comment:信息"`
	dto.ControlBy
}

func (m *GetSysLoginLogPageCommand) GetNeedSearch() interface{} {
	return *m
}

type GetSysLoginLogCommand struct {
	Id int64 `uri:"id"`
}

type RemoveSysLoginLogCommand struct {
	Ids []int64 `json:"ids"`
}

// Service 业务接口
type Service interface {
	GetSysLoginLogPage(ctx context.Context, cmd GetSysLoginLogPageCommand) (data []SysLoginLog, num int64, err error)
	Get(ctx context.Context, cmd GetSysLoginLogCommand) (SysLoginLog, error)
	InsertLoginLog(ctx context.Context, cmd *SysLoginLog) error
	Update(ctx context.Context, cmd SysLoginLog) error
	Remove(ctx context.Context, cmd RemoveSysLoginLogCommand) error

	// GetSysOperaLogPage 系统日志
	GetSysOperaLogPage(ctx context.Context, cmd GetSysOperaLogPageCommand) (data []SysOperaLog, num int64, err error)
	InsertOperLog(ctx context.Context, cmd *SysOperaLog) error
	GetSysOperaLog(ctx context.Context, cmd GetSysOperaLogCommand) (result SysOperaLog, err error)
}
